<html>
    <head>
        <title>构造函数</title>
        <script type="text/javascript">
        /*
            function CreatePerson(name, age, gender)
            {
                var obj = new Object();
                obj.name = name;
                obj.age = age;
                obj.gender = gender;
                obj.sayName = function()
                {
                    alert(this.name);
                }
                return obj;
            }

            var obj = CreatePerson("孙悟空",18,"男");
            obj.sayName();
            console.log(obj);
        */

            function Person(name, age, gender)
            {
                this.name = name;
                this.age = age;
                this.gender = gender;
                this.sayName = SayHello;
            }

            function SayHello()
            {
                alert("我是" + this.name);
            }

            var per = new Person("Wilde", 28, "男");
            per.sayName();
        </script>
    </head>

    <body>

    </body>
</html>